<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        class HttpError extends Error{
            constructor(params) {
                super(params);
               this.name="HttpError";
            }
        }
        let http=prompt("输入网址");
        
        new Promise((resolve,reject)=>{
             if(!/^www/i.test(http)){
              throw  new HttpError("网址错误");
             }
             resolve(http);
          
            
        }).then(value=>console.log(value),
      reason=>console.log(reason)
        ).catch(error=>{
            console.log(new Error("错误"));
        })
    </script>
</body>
</html>